/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package udpserver_pacmon;


import java.util.ArrayList;

public class Maze {

        private int mazeMaxRow, mazeMaxColumn; //by grids
        private int ghostSpawnLocX, ghostSpawnLocY;
        
        // 0 = wall, 1 = food, 2 = power, 3 = ghost door, 5 = blank, 6 = ghost
        private int maze1[][] = {
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},  //row 1
                        {0,1,1,1,1,0,1,1,1,0,1,1,1,1,0},
                        {0,2,0,0,1,0,1,0,1,0,1,0,0,2,0},
                        {5,1,1,1,1,1,1,1,1,1,1,1,1,1,5},
                        {0,0,1,0,0,0,0,1,0,0,0,0,1,0,0},  
                        {0,0,1,1,1,1,1,2,1,1,1,1,1,0,0},  //row 6
                        {0,0,1,0,0,1,0,0,0,1,0,0,1,0,0},
                        {0,1,1,5,5,5,5,5,5,5,5,5,1,1,0},
                        {0,1,0,0,5,0,0,0,0,0,5,0,0,1,0},
                        {0,1,0,0,5,0,6,6,6,0,5,0,0,1,0},  //row 10, monster cage
                        {0,1,0,0,5,0,0,3,0,0,5,0,0,1,0},
                        {0,1,1,5,5,5,5,5,5,5,5,5,1,1,0},  // door step
                        {0,0,1,0,0,1,0,5,0,1,0,0,1,0,0},
                        {0,0,1,1,1,1,1,2,1,1,1,1,1,0,0}, //row 14
                        {0,0,1,0,0,0,0,1,0,0,0,0,1,0,0},
                        {0,0,1,0,1,1,1,1,1,1,1,0,1,0,0},
                        {5,1,1,1,1,0,0,1,0,0,1,1,1,1,5},
                        {0,1,0,0,0,0,0,1,0,0,0,0,0,1,0},
                        {0,1,1,1,1,1,1,1,1,1,1,1,1,1,0},
                        {0,2,0,0,1,0,1,0,1,0,1,0,0,2,0},
                        {0,1,1,1,1,0,1,1,1,0,1,1,1,1,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                };
        
        private int directionMaze1[][] = {
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, // row 1
                        {0,1,0,0,2,0,1,0,2,0,1,0,0,2,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,3,7,0,8,0,8,7,8,0,8,0,7,4,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},  
                        {0,0,5,0,0,7,0,8,0,7,0,0,6,0,0}, // row 6
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,1,8,0,7,8,0,0,0,8,7,0,8,2,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, //row 10, ghost cage
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,3,7,0,8,7,0,7,0,7,8,0,7,4,0}, //monster door step, row 12
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,0,5,0,0,8,0,7,0,8,0,0,6,0,0}, // row 14
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,0,0,0,1,0,0,9,0,0,2,0,0,0,0},
                        {0,1,8,0,4,0,0,0,0,0,3,0,8,2,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,5,0,0,7,0,7,8,7,0,7,0,0,6,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,3,0,0,4,0,3,0,4,0,3,0,0,4,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
        };
        
        private int maze2[][] = {
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, // ro0 1
                        {0,1,1,1,1,0,1,1,1,0,1,1,1,1,0}, // ro0 2
                        {0,1,0,0,1,1,1,0,1,1,1,0,0,1,0},
                        {0,1,1,0,1,0,1,2,1,0,1,0,1,1,0}, // ro0 4
                        {0,0,1,0,1,0,0,0,0,0,1,0,1,0,0},
                        {0,1,1,0,1,1,1,1,1,1,1,0,1,1,0},
                        {0,1,0,0,1,0,0,0,0,0,1,0,0,1,0}, // ro0 7
                        {5,1,1,1,1,1,1,2,1,1,1,1,1,1,5},
                        {0,1,0,0,5,0,0,0,0,0,5,0,0,1,0},
                        {0,1,0,0,5,0,6,6,6,0,5,0,0,1,0}, // ro0 10
                        {0,1,0,0,5,0,0,3,0,0,5,0,0,1,0},
                        {0,1,5,5,5,5,5,5,5,5,5,5,5,1,0},
                        {0,1,0,5,0,5,0,5,0,5,0,5,0,1,0},
                        {0,1,0,5,0,5,5,5,5,5,0,5,0,1,0}, // ro0 14
                        {5,1,1,2,0,1,0,0,0,1,0,2,1,1,5},
                        {0,1,0,1,0,1,0,0,0,1,0,1,0,1,0},
                        {0,1,1,1,0,1,0,0,0,1,0,1,1,1,0},
                        {0,1,0,1,1,1,0,0,0,1,1,1,0,1,0},
                        {0,1,0,1,0,1,1,2,1,1,0,1,0,1,0}, // ro0 19
                        {0,1,0,1,0,0,1,0,1,0,0,1,0,1,0},
                        {0,1,1,1,1,1,1,1,1,1,1,1,1,1,0},                                                
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                };
        
        private int directionMaze2[][] = {
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, // row 1
                        {0,1,0,0,2,0,1,0,2,0,1,0,0,2,0},
                        {0,0,0,0,5,0,6,0,5,0,6,0,0,0,0},
                        {0,3,2,0,0,0,3,0,4,0,0,0,1,4,0}, // row 4
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},  
                        {0,1,4,0,5,0,0,0,0,0,6,0,3,2,0}, // row 6
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,5,0,0,9,0,0,0,0,0,9,0,0,6,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, //row 10, ghost cage
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,5,0,1,8,7,0,7,0,7,8,2,0,6,0}, //monster door step, row 12
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,0,0,0,0,5,0,8,0,6,0,0,0,0,0}, // row 14
                        {0,5,0,6,0,0,0,0,0,0,0,5,0,6,0},
                        {0,0,0,0,1,0,0,9,0,0,2,0,0,0,0},
                        {0,5,0,6,0,0,0,0,0,0,0,5,0,6,0}, // row 17
                        {0,0,0,5,0,6,0,0,0,5,0,6,0,0,0},
                        {0,0,0,0,0,3,7,0,7,4,0,0,0,0,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, // row 20
                        {0,3,0,8,0,0,8,0,8,0,0,8,0,4,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
        };
        
  // t1[0]= 0;
  // t1[1]= 9; // rd (right and down)
  // t1[2]=10; // ld
  // t1[3]= 5; // ru
  // t1[4]= 6; // lu
  // t1[5]=13; // rdu
  // t1[6]=14; // ldu
  // t1[7]=11; // rld
  // t1[8]= 7; // rlu
  // t1[9]=15; // rlud
        

/*      
        private int t2[][] = {
                        1];
                    t2[2]= [2];
                    t2[4]= [4];
                    t2[8]= [8];
                    t2[3]= [1, 2];
                    t2[9]= [1, 8];
                    t2[10]=[2, 8];
                    t2[12]=[4, 8];
                    t2[5]= [1, 4];
                    t2[6]= [2, 4];
                    t2[7]= [1, 2, 4];
                    t2[11]=[1, 2, 8];
                    t2[13]=[1, 4, 8];
                    t2[14]=[2, 4, 8];
                    t2[15]=[1, 2, 4, 8];;
        }
*/
        
        private ArrayList<Integer> t2[] = new ArrayList[16];
        private int foodCount = 125;
        
        
        public Maze() {
                mazeMaxRow = 22;
                mazeMaxColumn = 15;
                initArray();
                ghostSpawnLocX = 7;
                ghostSpawnLocY = 10;
        }

        public int[][] getMaze(int i) {
                if (i == 1) return maze1;
                if (i == 2) return maze2;
                return null;
        }
        
        public int getMazeRow(){
                return mazeMaxRow;
        }
        
        public int getMazeColumn(){
                return mazeMaxColumn;
        }
        
        public int getFoodCount(){
                return foodCount;
        }
        
        public void clearFood(int x, int y){
                maze1[x][y] = 5;
        }
        
        public int[][] getDirectionMaze(int i){
                if (i == 1) return directionMaze1;
                if (i == 2) return directionMaze2;
                return null;
        }
        
        public ArrayList<Integer>[] getGhostArray(){
                return t2;
        }
        
        private void initArray(){
                for (int i = 0; i < 16; i++){
                        t2[i] = new ArrayList<Integer>();
                }
                
                t2[1].add(1);
            t2[4].add(4);
            t2[8].add(8);
            t2[3].add(1); t2[3].add(2);
            t2[9].add(1); t2[9].add(8);
            t2[10].add(2); t2[10].add(8);
            t2[12].add(4); t2[12].add(8);
            t2[5].add(1); t2[5].add(4);
            t2[6].add(2); t2[6].add(4);
            
            t2[7].add(1); t2[7].add(2); t2[7].add(4);
            t2[11].add(1); t2[11].add(2); t2[11].add(8);
            t2[13].add(1); t2[13].add(4); t2[13].add(8);
            t2[14].add(2); t2[14].add(4); t2[14].add(8);
            
            t2[15].add(1); t2[15].add(2); t2[15].add(4); t2[15].add(8);
        }

        public int getGhostSpawnLocX() {
                // TODO Auto-generated method stub
                return 0;
        }

        public int getGhostSpawnLocY() {
                // TODO Auto-generated method stub
                return 0;
        }
}



/*Maze layout
                {"WWWWWWWWWWWWWWW"}, //1
                {"W....W...W....W"}, //2
                {"WoWW.WW.WW.WWoW"}, //3
                {"W.............W"},
                {"WW.WWWW.WWWW.WW"}, //5
                {"WW.....o.....WW"},
                {"WW.WW.WWW.WW.WW"},
                {"W..---------..W"},
                {"W.WW-WWWWW-WW.W"},
                {"W.WW-WGGGW-WW.W"}, //10
                {"W.WW-WWDWW-WW.W"},
                {"W..---------..W"},
                {"WW.WW.WWW.WW.WW"},
                {"WW.....o.....WW"},
                {"WW.WWWW.WWWW.WW"}, //15
                {"WW.W.......W.WW"},
                {"W....WW.WW....W"},
                {"W.WWWWW.WWWWW.W"},
                {"W.............W"},
                {"WoWW.WW.WW.WWoW"}, //20
                {"WWWWWWWWWWWWWWW"}
                
                
                maze 2
                        {"WWWWWWWWWWWWWWW"}, // row 1
                        {"W....W...W....W"}, // row 2
                        {"W.WW...W...WW.W"},
                        {"W..W.W...W.W..W"}, // row 4
                        {"WW.W.WWWWW.W.WW"},
                        {"W..W.......W..W"},
                        {"W.WW.WWWWW.WW.W"}, // row 7
                        {"W.............W"},
                        {"W.WW-WWWWW-WW.W"},
                        {"W.WW-WGGGW-WW.W"}, // row 10
                        {"W.WW-WWDWW-WW.W"},
                        {"W.-----------.W"},
                        {"W.W.W.W-W.W.W.W"},
                        {"W.W.W.---.W.W.W"}, // row 14
                        {"W...W.WWW.w...W"},
                        {"W.W.W.WWW.W.W.W"},
                        {"W...W.WWW.W...W"},
                        {"W.W...WWW...W.W"},
                        {"W.W.W.....W.W.W"}, // row 19
                        {"W.W.WW.W.WW.W.W"},
                        {"W.............W"},                                            
                        {"WWWWWWWWWWWWWWW"},
                        
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,3,7,0,8,0,8,7,8,0,8,0,7,4,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},  
                        {0,0,5,0,0,7,0,8,0,7,0,0,6,0,0}, // row 6
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,1,8,0,7,8,0,0,0,8,7,0,8,2,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, //row 10, ghost cage
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,3,7,0,8,7,0,7,0,7,8,0,7,4,0}, //monster door step, row 12
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,0,5,0,0,8,0,7,0,8,0,0,6,0,0}, // row 14
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,0,0,0,1,0,0,9,0,0,2,0,0,0,0},
                        {0,1,8,0,4,0,0,0,0,0,3,0,8,2,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,5,0,0,7,0,7,8,7,0,7,0,0,6,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,3,0,0,4,0,3,0,4,0,3,0,0,4,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                
                
                {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                {0,1,1,1,1,0,1,1,1,0,1,1,1,1,0},
                {0,2,0,0,1,0,0,1,0,0,1,0,0,2,0},
                {0,1,1,1,1,1,1,1,1,1,1,1,1,1,0},
                {0,0,1,0,0,0,0,1,0,0,0,0,1,0,0},
                {0,0,1,0,0,0,0,1,0,0,0,0,1,0,0},
                {0,0,1,1,1,1,1,2,1,1,1,1,1,0,0},
                {0,0,1,0,0,1,0,0,0,1,0,0,1,0,0},
                {0,1,1,5,5,5,5,5,5,5,5,5,1,1,0},
                {0,1,0,0,5,0,0,3,0,0,5,0,0,1,0},
                {0,1,0,0,5,0,6,6,6,0,5,0,0,1,0},
                {0,1,0,0,5,0,0,0,0,0,5,0,0,1,0},
                {0,1,1,5,5,5,5,5,5,5,5,5,1,1,0},
                {0,0,1,0,0,1,0,0,0,1,0,0,1,0,0},
                {0,0,1,1,1,1,1,2,1,1,1,1,1,0,0},
                {0,0,1,0,0,0,0,1,0,0,0,0,1,0,0},
                {0,0,1,0,1,1,1,1,1,1,1,0,1,0,0},
                {0,1,1,1,1,0,0,1,0,0,1,1,1,1,0},
                {0,1,0,0,0,0,0,1,0,0,0,0,0,1,0},
                {0,1,1,1,1,1,1,1,1,1,1,1,1,1,0},
                {0,2,0,0,1,0,0,1,0,0,1,0,0,2,0},
                {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
*/